package com.zcmyth;

import org.junit.Test;

import com.zcmyth.collection.MinStack;

import static org.junit.Assert.assertEquals;

public class MinStackTest {

  @Test
  public void test() {
    MinStack<Integer> stack = new MinStack<Integer>();
    assertEquals(null, stack.min());
    
    stack.push(1);
    assertEquals(Integer.valueOf(1), stack.min());
    
    stack.push(3);
    assertEquals(Integer.valueOf(1), stack.min());
    
    stack.push(2);
    assertEquals(Integer.valueOf(1), stack.min());
    
    stack.push(0);
    assertEquals(Integer.valueOf(0), stack.min());
    
    stack.push(5);
    assertEquals(Integer.valueOf(0), stack.min());
    
    stack.push(-1);
    assertEquals(Integer.valueOf(-1), stack.min());
    
    stack.pop();
    assertEquals(Integer.valueOf(0), stack.min());
    
    stack.pop();
    assertEquals(Integer.valueOf(0), stack.min());
    
    stack.pop();
    assertEquals(Integer.valueOf(1), stack.min());
    
    stack.pop();
    assertEquals(Integer.valueOf(1), stack.min());
  }
}
